const pets = [
  { gender: "男", name: "张三" },
  { gender: "女", name: "李四" },
  { gender: "男", name: "王五" },
];

const res = Object.groupBy(pets, (pet) => pet.gender);
console.log(res);
